import { useUserStore } from "@/stores/userStore";
import type { Directive, DirectiveBinding } from "vue";


// 管理员账号单独处理
const adminPerms = '*:*:*';

export const auth: Directive = {
  mounted(el:HTMLElement, binding:DirectiveBinding) {
    const { value } = binding
    console.log(value)

    const store = useUserStore()
    const perms = store.profile.permissions
    if(perms.includes(adminPerms)) {
      return
    }

    if(!perms.includes(value)) {
      el.remove()
    }
  },
}
